package nina.yiyou.attendance.s20sum.start

import nina.yiyou.attendance.s20sum.compute.AttendDetailSummarizer
import nina.yiyou.attendance.s20sum.input.AttendDetailCsvReader
import nina.yiyou.attendance.s20sum.output.DetailSumGenerator
import nina.yiyou.attendance.s20sum.output.salary.SumForSalaryGenerator
import nina.yiyou.salary.process.global.GlobalResultMaker

/**
 * 生成 20考勤汇总表 和 40工资用考勤表
 */
class AttendStep20Runner {

  AttendStep20Runner(List attendDetailList, GlobalResultMaker.Result globalResult) {
    _attendDetailList = attendDetailList
    _globalResult = globalResult
  }

  void run() {
    List detailList = new AttendDetailCsvReader(_attendDetailList).read()
    List<Map> employeeResult = makeSumResult(detailList)

    new DetailSumGenerator(employeeResult, _globalResult).generate()
    new SumForSalaryGenerator(_globalResult, employeeResult).generate()
  }

  private List<Map> makeSumResult(List detailList) {
    return new AttendDetailSummarizer(detailList).sum()
  }

  private final List _attendDetailList

  private final GlobalResultMaker.Result _globalResult
}
